/**
 * THPS Dedicated Server
**/

#ifndef _THPS_
    #define _THPS_ 1

    #define CRC32_POLY 0xedb88320
    #define recvpacket(fd, buf, bufsz, x) \
            if( !recv(fd, buf, bufsz, x) ) \
                stderr("Error receiving packet"); \
            \
            DecodePacket(buf, bufsz);


    /** THPS CRC Table **/
    unsigned long crc32_table[256];

    /** THPS CRC specific functions **/
    void CreateCRCTable();
    unsigned short GeneratePacketCRC(unsigned char *buffer, unsigned long bufferSize);
    void DecodePacket(unsigned char *packet, unsigned long packetSize);
    void EncodePacket(unsigned char *packet, unsigned long packetSize);
#endif
